
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections;
using System.Diagnostics;

using Swaf;
using Swaf.BizObj;
using Swaf.BizRule;
using Swaf.Security;
using Swaf.Gui;


namespace MediaCache.Gui
{
    /// <summary>
    /// 
    /// </summary>
    public class MediaDirectoryBizProc : BaseBusinessProcess
    {

		public MediaDirectoryBizProc(ActiveBizProc procState)
            :base(procState)
        {
        }

		public override Privileges CurrentEditPrivilege { get { return Privileges.Delete; } }
		protected override void setupRuleNames()
		{
			base.m_getBizObjListRule = "getMediaItemDirectories";
			base.m_updateBizObjRule = "updateMediaDirectory";
			base.m_deleteBizObjRule = "deleteMediaDirectory";
		}

		protected override object[] getDeleteRuleParameters(object bizObjKey)
		{
			updateBizObj(true);
			return new object[] { CurrentBizObj };
		}

		protected override object[] getBizObjListRuleParameters(object parentId, IBizObj filterSort)
		{
			return new object[] { parentId };
		}
		protected override string BizObjTypeName
		{
			get
			{
				return "MediaItemDirectory";
			}
		}
		public override IBizObj createNewBizObj()
		{
			IBizObj newDir = App.bizObjMgr.create(BizObjTypeName);
			newDir.put("parentName", CurrentBizObj.get("keyName"));
			newDir.put("cacheName", CurrentBizObj.get("cacheName"));
			return newDir;
		}

		public override void updateBizObj()
		{
			base.updateBizObj();
			base.refreshListControls();
		}
	}
}
